package com.woniu.microuserserver.service.impl;

import com.github.pagehelper.ISelect;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.microcommonsserver.entity.UserInfoEntity;
import com.woniu.microuserserver.bean.SearchQuery;
import com.woniu.microuserserver.bean.UserBean;
import com.woniu.microuserserver.mapper.UserMapper;
import com.woniu.microuserserver.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class UserServiceimpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public UserBean login(UserBean userBean) {
        return null;
    }

    @Override
    public PageInfo<UserInfoEntity> searchByquery(SearchQuery searchQuery) {
        PageInfo<UserInfoEntity> pageInfo = PageHelper.startPage(searchQuery.getCurrentPage(),searchQuery.getPageSize()).doSelectPageInfo(new ISelect() {
            @Override
            public void doSelect() {
                userMapper.searchByquery(searchQuery);
            }
        });
        return pageInfo;
    }

    @Override
    public int addUser(UserInfoEntity userInfoEntity) {
        return userMapper.addUser(userInfoEntity);
    }

    @Override
    public UserInfoEntity searchOneByname(String loginName) {
        return userMapper.searchOneByname(loginName);
    }

    @Override
    public int changeUser(UserInfoEntity userInfoEntity) {
        return userMapper.changeUser(userInfoEntity);
    }

    @Override
    public int delUser(String loginName) {
        return userMapper.delUser(loginName);
    }

    @Override
    public int stopUser(String loginName, String status) {
        final int i = userMapper.stopUser(loginName, status);
        return i;
    }

    @Override
    public int resetpd(String loginName) {
        return userMapper.resetpd(loginName);
    }

    @Override
    public List<UserInfoEntity> searchbyids(int[] ids) {
        return userMapper.searchbyids(ids);
    }

    @Override
    public List<String> searchdepname() {
        return userMapper.searchdepname();
    }

    @Override
    public List<UserInfoEntity> searchfour() {
        return userMapper.searchfour();
    }

    @Override
    public List<Integer> searchRidsByUid(int uid) {
        return userMapper.searchRidsByUid(uid);
    }

    @Override
    public UserInfoEntity searchByUid(int uid) {
        return userMapper.searchByUid(uid);
    }

}
